import request from '@/utils/sphRequest'

export interface InfoData {
  phone: string
  password: string
  code?: string
  data?: string
}

interface TokenData {
  token: string
  code?: string | undefined
}

//获取验证码
export const getPhoneCode = (phone: string) => {
  return request.get<any, any>(`/api/user/passport/sendCode/${phone}`)
}

//用户注册
export const getRegister = (info: InfoData) => {
  return request.post<any, any>('/api/user/passport/register', info)
}
//用户登录
export const getLogin = (info: InfoData) => {
  return request.post<any, TokenData>('/api/user/passport/login', info)
}
//退出登录
export const LogOut = () => {
  return request.get<any, null>('/api/user/passport/logout')
}
export default {
  getPhoneCode,
  getRegister,
  getLogin,
  LogOut
}
